package com.example.controller;

import com.example.pojo.Indent;
import com.example.pojo.Result;
import com.example.service.impl.ContractpayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.List;
@CrossOrigin
@RestController
public class ContractpayController {
    @Autowired
    private ContractpayServiceImpl contractpayService;

    @Autowired
    private HttpServletRequest request;

    //租客显示支付记录
    @GetMapping("/paymentz")
    public Result getPaymentZ(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")LocalDateTime date){
        List<Indent> list=contractpayService.getPayment(date,request);
        return Result.success(list);
    }

    //房东显示支付记录
    @GetMapping("/paymentf")
    public Result getPaymentF(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")LocalDateTime date){
        List<Indent> list=contractpayService.getPaymentF(date,request);
        return Result.success(list);
    }

    //租客合同显示
    @GetMapping("/contractzk")
    public Result getContractZk(String fname){
        List<Indent> list=contractpayService.getContractZK(fname,request);
        return Result.success(list);
    }

    //房东显示当前合同
    @GetMapping("/contractfj")
    public Result getContractFJ(String name){
        List<Indent> list=contractpayService.getContractFJ(name,request);
        return Result.success(list);
    }

    //房东显示历史合同
    @GetMapping("/contractfl")
    public Result getContractFl(String name){
        List<Indent> list=contractpayService.getContractFL(name,request);
        return Result.success(list);
    }

    //租客显示具体合同信息
    @GetMapping("/contractzk/{id}")
    public Result getContractIdZk(@PathVariable Integer id){
        Indent indent=contractpayService.getContractIdZk(id,request);
        return Result.success(indent);
    }

    //房东显示具体合同信息
    @GetMapping("/contractf/{id}")
    public Result getContractIdF(@PathVariable Integer id){
        Indent indent=contractpayService.getContractIdF(id,request);
        return Result.success(indent);
    }
}
